home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / gprim / discgrp / outstack.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-16  |  1.2 KB  |  55 lines

  1. /* This file is for managing the output stack of group elements */
  2.  
  3. #include "discgrpP.h"
  4.  
  5.     static int BlockSize, array_size;
  6.     static DiscGrpEl *mystack = NULL, *stackptr = NULL;
  7.        static int count = 0, debug = 0;
  8.  
  9. int
  10. init_out_stack()
  11. {
  12.         array_size = 1;
  13.         BlockSize = 1024;
  14.     count = 0;
  15.         if ((mystack = OOGLNewN (DiscGrpEl, BlockSize )) == (DiscGrpEl *) NULL) return(0);
  16.     stackptr = mystack;
  17.     return(1);
  18. }
  19.     
  20. int
  21. enumpush(pp)
  22. DiscGrpEl *pp;
  23. {
  24.     register int i;
  25.     if (stackptr >= &mystack[BlockSize*array_size])    { 
  26.     if (debug) 
  27.         fprintf(stderr,"allocating again: size is now %d\n",array_size*BlockSize);
  28.     array_size = array_size*2;
  29.         if ((mystack = OOGLRenewN(DiscGrpEl,mystack, array_size*BlockSize)) == (DiscGrpEl *) NULL) return (0);
  30.     stackptr = &mystack[count];
  31.     }
  32.     *stackptr = *pp;
  33.     TmCopy(pp->tform, stackptr->tform); 
  34.     stackptr++;
  35.     count++;
  36.     return(1);
  37. }
  38.     
  39. int
  40. enumgetsize()
  41. {
  42.     return(count);
  43. }
  44.  
  45. DiscGrpEl *
  46. enumgetstack()
  47. {
  48.     DiscGrpEl *thisptr;
  49.     thisptr = OOGLNewN (DiscGrpEl, count );
  50.     if (thisptr == NULL) return ( (DiscGrpEl *) NULL);
  51.     bcopy(mystack, thisptr, sizeof(DiscGrpEl) * count);
  52.     OOGLFree(mystack);
  53.     return(thisptr);
  54. }
  55.